package com.xy.template.model;

import com.xy.template.constant.JavaNameUtil;

public class PageAttribute {

    public static final int FORM_WIDTH_SIZE = 2;

    private String name = "";
    private String type = "";
    private String label = "";
    private String queryShow = "";
    private String formShow = "";
    private String listShow = "";

    private String width = "";
    private String height = "";
    private Integer sort;
    private String likeQuery = "";
    private String batchQuery = "";
    private String onlyQuery = "";
    private String showType = "";
    private String dictCode = "";
    private String pascalName = "";

    public int getFlag() {
        if (name != null && name.trim().length() > 0) {
            return 1;
        }
        return 0;
    }

    public String getName() {
        return name;
    }

    public String getPascalName() {
        return pascalName;
    }

    public void setPascalName(String pascalName) {
        this.pascalName = pascalName;
    }

    public void setName(String name) {
        this.name = name;
        this.pascalName = JavaNameUtil.toPascal(name);
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public String getQueryShow() {
        return queryShow;
    }

    public void setQueryShow(String queryShow) {
        this.queryShow = queryShow;
    }

    public String getFormShow() {
        return formShow;
    }

    public void setFormShow(String formShow) {
        this.formShow = formShow;
    }

    public String getListShow() {
        return listShow;
    }

    public void setListShow(String listShow) {
        this.listShow = listShow;
    }

    public int getWidthNum() {
        int widthNum = 1;
        try {
            widthNum = Integer.valueOf(width);
        } catch (Exception ex) {

        }
        return widthNum;
    }

    public int getColspanSize() {
        return getWidthNum() * FORM_WIDTH_SIZE - 1;
    }

    public String getWidth() {
        return width;
    }

    public void setWidth(String width) {
        this.width = width;
    }

    public String getHeight() {
        return height;
    }

    public void setHeight(String height) {
        this.height = height;
    }

    public Integer getSort() {
        return sort;
    }

    public Long getSortNum() {
        Long sort1 = 10000L;
        try {
            sort1 = Long.valueOf(sort);
        } catch (Exception ex) {

        }
        return sort1;
    }


    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public String getLikeQuery() {
        return likeQuery;
    }

    public void setLikeQuery(String likeQuery) {
        this.likeQuery = likeQuery;
    }


    public String getBatchQuery() {
        return batchQuery;
    }

    public void setBatchQuery(String batchQuery) {
        this.batchQuery = batchQuery;
    }


    public String getOnlyQuery() {
        return onlyQuery;
    }

    public void setOnlyQuery(String onlyQuery) {
        this.onlyQuery = onlyQuery;
    }

    public String getInputType() {
        if ("BigDecimal".equalsIgnoreCase(this.type)
                || "Long".equalsIgnoreCase(this.type)
                || "Double".equalsIgnoreCase(this.type)
                || "Integer".equalsIgnoreCase(this.type)) {
            return "number";
        }
        return "string";
    }

    public String getShowType() {
        return showType;
    }

    public void setShowType(String showType) {
        this.showType = showType;
    }

    public String getDictCode() {
        return dictCode;
    }

    public void setDictCode(String dictCode) {
        this.dictCode = dictCode;
    }
}
